package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.CFacility;
import com.ruoyi.camp.domain.CFacilityType;
import com.ruoyi.camp.domain.WxCampFacilityVo;
import com.ruoyi.camp.service.ICFacilityService;
import com.ruoyi.camp.service.IWxFacilityService;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Anonymous
@RestController
@RequestMapping("/wechat/facility")
public class WxFacilityController extends BaseController {


    @Autowired
    private IWxFacilityService iWxFacilityService;


    @GetMapping("/list")
    public TableDataInfo list(CFacilityType cFacilityType)
    {
        List<CFacilityType> list = iWxFacilityService.facilityTypeList(cFacilityType);
        return getDataTable(list);
    }

    /**
     * 新增facility
     */
    @PostMapping("/add")
    public AjaxResult add(@RequestBody WxCampFacilityVo wxCampFacilityVo)
    {
        return toAjax(iWxFacilityService.insertCampFacility(wxCampFacilityVo.getCampId(),wxCampFacilityVo.getFacilityIds()));
    }
}
